﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Finance_accounts : System.Web.UI.Page
{
    //private Bill _CurrentBill = null;
    ///// <summary>
    ///// 当前清单
    ///// </summary>
    //protected Bill CurrentBill
    //{
    //    get
    //    {
    //        if (_CurrentBill == null)
    //        {
    //            if (Request.QueryString["BillId"] != null && Request.QueryString["BillId"].Length > 0)
    //            {
    //                _CurrentBill = Bill.Load(Convert.ToInt32(Request.QueryString["BillId"]));
    //            }
    //            else
    //            {
    //                Response.Redirect("~/Bill", true);
    //            }
    //        }
    //        return _CurrentBill;
    //    }
    //}

    //protected void Page_Load(object sender, EventArgs e)
    //{
    //    if (!IsPostBack)
    //    {
    //        if (Request.UrlReferrer == null )
    //        {
    //            this.Response.Write("请不要非法进入本页！<br/>3秒后将转回....");
    //            this.Response.Write("<script type=\"text/javascript\">setTimeout(\"location.href='../Finance/'\",3*1000);</script>");
    //            this.Response.End();
    //            return;
    //        }
    //        else
    //        {
    //            this.lblHeadCustomerName.Text += CurrentBill.Customer.Name;
    //            this.lblHeadPactCode.Text = CurrentBill.Number;
    //            this.imgBillFinanceAudit.ImageUrl = string.Format("~/pics/audit{0}.gif", CurrentBill.FinanceAudit.ToString());
    //            if (Request.QueryString["Type"] == "Customer")
    //            {
    //                this.gvOrderListByBillId.Columns[9].Visible = false;
    //                this.gvOrderListByBillId.Columns[4].Visible = false;
    //                this.gvOrderListByBillId.Columns[5].Visible = false;
    //                this.gvOrderListByBillId.Columns[6].Visible = false;
    //                this.gvOrderListByBillId.Columns[7].Visible = false;
    //            }
    //            this.gvOrderListByBillId.DataSource = CurrentBill.Orders;
    //            this.gvOrderListByBillId.DataBind();
    //        }
    //    }
    //}
    //protected void gvOrderListByBillId_RowDataBound(object sender, GridViewRowEventArgs e)
    //{
    //    if (e.Row.RowType == DataControlRowType.DataRow)
    //    {
    //        Order order = e.Row.DataItem as Order;
    //        //客户（收款）结算绑定
    //        Audit customerAudit = order.FinanceAudit;
    //        LinkButton lbtnCustomerFinanceAudit = e.Row.FindControl("lbtnCustomerAudit") as LinkButton;
    //        HyperLink hlGotoAndGetIncome = e.Row.FindControl("hlGotoAndGetIncome") as HyperLink;
    //        lbtnCustomerFinanceAudit.Visible = false;
    //        lbtnCustomerFinanceAudit.Text = "结算";
    //        lbtnCustomerFinanceAudit.CommandName = "CustomerBalance";
    //        if (customerAudit == Audit.Working)
    //        {
    //            lbtnCustomerFinanceAudit.Visible = true;
    //        }
    //        else if (customerAudit == Audit.Success)
    //        {
    //            hlGotoAndGetIncome.Text = "详细收款";
    //            if (Utils.IsGeneralManager)
    //            {
    //                lbtnCustomerFinanceAudit.Visible = true;
    //                lbtnCustomerFinanceAudit.Text = "反结算";
    //                lbtnCustomerFinanceAudit.CommandName = "CancelCustomerBalance";
    //            }
    //        }
    //        //媒体（付款）结算绑定
    //        Audit mediaAudit = order.MediaFinanceAudit;
    //        LinkButton lbtnMediaFinanceAudit =
    //            e.Row.FindControl("lbtnMediaAudit") as LinkButton;
    //        HyperLink hlGotoPay = e.Row.FindControl("hlGotoPay") as HyperLink;
    //        lbtnMediaFinanceAudit.Visible = false;
    //        lbtnMediaFinanceAudit.Text = "结算";
    //        lbtnMediaFinanceAudit.CommandName = "MediaBalance";
    //        if (mediaAudit == Audit.Working)
    //        {
    //            lbtnMediaFinanceAudit.Visible = true;
    //        }
    //        else if (mediaAudit == Audit.Success)
    //        {
    //            hlGotoPay.Text = "详细付款";
    //             if ( Utils.IsGeneralManager )
    //            {
    //                lbtnMediaFinanceAudit.Visible = true;
    //                lbtnMediaFinanceAudit.Text = "反结算";
    //                lbtnMediaFinanceAudit.CommandName = "CancelMediaBalance";
    //            }
    //        }

    //        if (order.Bill.FinanceAudit == Audit.Success)
    //        {
    //            hlGotoPay.Text = "详细付款";
    //            hlGotoAndGetIncome.Text = "详细收款";
    //            lbtnCustomerFinanceAudit.Visible = false;
    //            lbtnMediaFinanceAudit.Visible = false;
    //        }
    //        if (Utils.IsGeneralManager)
    //        {
    //            lbtnCustomerFinanceAudit.Visible = true;
    //            lbtnMediaFinanceAudit.Visible = true;
    //        }
    //    }
    //}

    //protected void gvOrderListByBillId_RowCommand(object sender, GridViewCommandEventArgs e)
    //{
    //    if (e.CommandName == "CustomerBalance")
    //    {
    //        Order order = Order.GetOrder(Convert.ToInt32(e.CommandArgument));
    //        order.ConfirmCustomerBalance();
    //        order.Save();
    //    }
    //    if (e.CommandName == "CancelCustomerBalance")
    //    {
    //        Order order = Order.GetOrder(Convert.ToInt32(e.CommandArgument));
    //        order.CancelCustomerBalance();
    //        order.Save();
    //    }
    //    if (e.CommandName == "MediaBalance")
    //    {
    //        Order order = Order.GetOrder(Convert.ToInt32(e.CommandArgument));
    //        order.ConfirmMediaBalance();
    //        order.Save();
    //    }
    //    if (e.CommandName == "CancelMediaBalance")
    //    {
    //        Order order = Order.GetOrder(Convert.ToInt32(e.CommandArgument));
    //        order.CancelMediaBalance();
    //        order.Save();
    //    }
    //    this.gvOrderListByBillId.DataSource = CurrentBill.Orders;
    //    this.gvOrderListByBillId.DataBind();
    //}
}
